<?php

namespace App\Model;

use App\BaseModel;

class UserWithdraw extends BaseModel
{
    protected $table = "user_withdraws";

    public function getStateNameAttribute()
    {
        $a = [0=>"待审核",1=>"已审核",2=>"已提现",3=>"已拒绝"];
        return isset($a[$this->state])?$a[$this->state]:$this->state;
    }

    public function createHistory($admin_id)
    {
       $uwh = new UserWithdrawHistory();
       $uwh->withdraw_id=$this->id;
       $uwh->status = $this->state;
       $uwh->admin_id = $admin_id;
       $uwh->remark = $this->remark;
       return $uwh->save();
    }
}
